﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class StartAnimation : MonoBehaviour
{

    public Animator animator;


    public void PlayAniamtion()
    {
        animator.SetBool("FadeIn", true);
    }
    public void LoadStartScene()
    {
        StartCoroutine(LoadFirstDialogSceneAfterAnimation());
    }

    private IEnumerator LoadFirstDialogSceneAfterAnimation()
    {

        Scene currentActiveScene = SceneManager.GetActiveScene();
        AsyncOperation ao = SceneManager.LoadSceneAsync("FirstDialogScene", LoadSceneMode.Additive); // 使用 Additive 模式加载新场景
        Scene newScene = SceneManager.GetSceneByName("FirstDialogScene");
        yield return ao;
        // 设置新加载的场景为活跃场景
        SceneManager.SetActiveScene(newScene);
        // 卸载原来的活跃场景
        SceneManager.UnloadSceneAsync(currentActiveScene);
    }

}
